[SQL] Select 3 lastest order for each customer
Posted
by Ratiug
on Stack Overflow
See other posts from Stack Overflow
or by Ratiug
Published on 2010-05-07T18:23:14Z
Indexed on
2010/05/07
18:28 UTC
Read the original article
Hit count: 118
sql-server-2005
Hi
Here is my table CusOrder that collect customer order
OrderID Cus_ID Product_ID NumberOrder OrderDate
1 0000000001 9 1 6/5/2553 0:00:00
2 0000000001 10 1 6/5/2553 0:00:00
3 0000000004 9 2 13/4/2553 0:00:00
4 0000000004 9 1 17/3/2553 0:00:00
5 0000000002 9 1 22/1/2553 0:00:00
7 0000000005 9 1 16/12/2552 0:00:00
8 0000000003 9 3 13/12/2552 0:00:00
10 0000000001 9 2 19/11/2552 0:00:00
11 0000000003 9 2 10/11/2552 0:00:00
12 0000000002 9 1 23/11/2552 0:00:00
I need to select 3 lastest order for each customer and I need all customer so it will show each customer and his/her 3 lastest order how can I do it
sorry for my bad english
© Stack Overflow or respective owner